package utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import com.mysql.jdbc.StringUtils;


public class SystemParm {


	public static final Properties SystemParm = new Properties();
	
	public static  void load(String filePath) throws IOException {

			InputStream is = new FileInputStream(new File(filePath));
			if( is!= null) {
				SystemParm.load(is);
			}
	}
	
	public static String getParm(String parmName){
		String value = SystemParm.getProperty(parmName);
		if (value == null)
			value = "";
		return value.trim();
	}
	
	public static String getSrc() {
		return getParm("src");
	}
	
	public static String getDes() {
		return getParm("des");
	}
	
	public static int getSize() {
		return Integer.parseInt(getParm("size"));
	}
	
	public static String getSrcTwo() {
		return getParm("src2");
	}
	
	
	
	//源文件夹
	public static String getSourcePath() {
		return getParm("sourcePath");
	}
	//目标文件夹
	public static String getPicPath() {
		return getParm("picPath");
	}
	//备份文件夹
	public static String getBackupPicPath() {
		return getParm("backupPicPath");
	}
	//日志文件夹
	public static String getLogSuccessPath() {
		return getParm("logSuccessPath");
	}
	//日志文件夹
	public static String getLogErrorPath() {
		return getParm("logErrorPath");
	}
	
	//需求文件夹
	public static String getRequiredFolder () {		 
		return getParm("requiredFolder");
	}
	
	
	//获取提取图片文件夹
	public static String getExtract() {		 
		return getParm("des_tiqu");
	}
	
	
	
	// 获取提取图片的年份id
	public static Integer getYearId() {
		return Integer.valueOf(getParm("year_id"));
	}
	
	// 获取提取图片的季度id
	public static List<Integer> getQuarterIds() {
		List<Integer> list = new ArrayList<Integer>();
		String[] quarterArrays =  getParm("quarter_id").split(",");
		if (quarterArrays.length !=0) {
			for (int i = 0; i < quarterArrays.length; i++) {
				list.add(Integer.valueOf(quarterArrays[i]));
			}
		}
		return list;
	}
	
	// 获取提取图片的品牌id
	public static List<Integer> getBrandIds() {
		List<Integer> list = new ArrayList<Integer>();
		String brand = getParm("brand_id").trim();
		String[] brandArrays = {};
		if (!brand.equals("")) {
			brandArrays =  brand.split(",");
		}	
		if (brandArrays.length !=0) {
			for (int i = 0; i < brandArrays.length; i++) {
				if (brandArrays[i] != null && brandArrays[i] != "") {
					list.add(Integer.valueOf(brandArrays[i]));
				} else {
					continue;
				}
			}
		}			
		return list;
	}
	
	
	public static void main(String[] args) throws IOException  {
//		SystemParm systemParm = new SystemParm();
//		systemParm.load();

	}

	

}
